package com.foot.travel.activity;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.foot.travel.R;
import com.foot.travel.viewholder.OtherClassTravelViewHolder;
import com.koalac.ironman.common.adapter.CommonAdapter;
import com.koalac.ironman.common.module.ModuleActivity;
import com.koalac.ironman.net.pojo.request.GetOtherClassTravelList;
import com.koalac.ironman.net.pojo.response.SchoolTravelItem;
import com.koalac.ironman.viewhelper.ViewInject;
import com.koalac.ironman.widget.PullToRefreshView;
import com.koalac.ironman.widget.PullToRefreshView.OnFooterRefreshListener;
import com.koalac.ironman.widget.PullToRefreshView.OnHeaderRefreshListener;

public class OtherClassTravelActivity extends ModuleActivity implements
	OnHeaderRefreshListener, OnFooterRefreshListener {
    @ViewInject(id = R.id.other_class_travel_container)
    PullToRefreshView mOtherClassTravelContainer;
    @ViewInject(id = R.id.other_class_travel_listview)
    ListView mOtherClassTravelListview;

    public CommonAdapter<SchoolTravelItem> mOtherTravelItemAdapter;
    GetOtherClassTravelList mGetOtherClassTravelList;
    public List<SchoolTravelItem> mOtherTravelItems = new ArrayList<SchoolTravelItem>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setBackButtonVisibility(true);
	setNavigationTitle("同学去哪儿");
	initOtherClassList();
    }

    public void initOtherClassList() {
	mGetOtherClassTravelList = new GetOtherClassTravelList();
	mOtherTravelItemAdapter = new CommonAdapter<SchoolTravelItem>(
		OtherClassTravelViewHolder.class, mOtherTravelItems,
		OtherClassTravelActivity.this, R.layout.other_travel_item);
	mOtherClassTravelListview.setAdapter(mOtherTravelItemAdapter);
	loadData(SchoolTravelItem.class, LoadState.init,
		mGetOtherClassTravelList, mOtherClassTravelContainer,
		mOtherTravelItemAdapter, mOtherTravelItems);
	mOtherClassTravelContainer.setOnHeaderRefreshListener(this);
	mOtherClassTravelContainer.setOnFooterRefreshListener(this);
    }

    @Override
    protected void initLayout(ViewGroup rootContentView) {
	addContentView(R.layout.activity_other_class_travel);
    }

    @Override
    public void onFooterRefresh(PullToRefreshView view) {
	loadData(SchoolTravelItem.class, LoadState.more,
		mGetOtherClassTravelList, mOtherClassTravelContainer,
		mOtherTravelItemAdapter, mOtherTravelItems);
    }

    @Override
    public void onHeaderRefresh(PullToRefreshView view) {
	loadData(SchoolTravelItem.class, LoadState.refresh,
		mGetOtherClassTravelList, mOtherClassTravelContainer,
		mOtherTravelItemAdapter, mOtherTravelItems);
    }


}
